package com.jala.base;

import com.jala.umf.common.model.UserVO;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/3/13.
 */
public class Global {
    public static UserVO getUserInfo() {

        Subject subject = SecurityUtils.getSubject();
        List list = subject.getPrincipals().asList(); //z,{login_id=z, user_name=测试用户, user_id=4518}
//	        String name = (String) list.get(0);
        Map<String, Object> attributes = (Map<String, Object>)list.get(1);
        UserVO ui = new UserVO();
        ui.setId(NumberUtils.toInt((String)attributes .get("user_id")));//用户ID
        ui.setFullName((String) attributes .get("user_name"));//用户名称
        ui.setUserName((String) attributes .get("login_id"));//用户的登陆账号

        return ui;
    }
}
